<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	Mar 21, 2012
 ^
 + Project: 		WRecruit
 * File Name:	views/jobseeker/tmpl/listnewestjobs.php
 ^ 
 * Description: template view for newest jobs
 ^ 
 * History:		NONE
 ^ 
 */
 
 defined('_JEXEC') or die('Restricted access');

 global $mainframe;
 $document =& JFactory::getDocument();
 $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);
		$link = ("index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=listnewestjobs&Itemid=".$this->Itemid);
	
 $jobcatlink = JRoute::_('index.php?option=com_wrecruit&c=wrecruit&view=jobseeker&layout=jobcat&Itemid='.$this->Itemid);

/*if (isset($this->userrole->rolefor)){
	if ($this->userrole->rolefor != ''){
		if ($this->userrole->rolefor == 2) // job seeker
			$allowed = true;
		else
			$allowed = false;
	}else{
		$allowed = true;
	}
}else */

//public space for everyone
$allowed = true; // user not logined

?>
<div class="box-list latest-job">
	<div class="head-title">
		<h2><?php echo JText::_('Latest Jobs');  ?></h2>
	</div>

<?php
if ($allowed == true) { 

if (isset($this->jobs)) {

?>
<?php 
	if ( isset($this->jobs) ){
		$numitems = count($this->jobs);
		$first_row = (int)($numitems / 2);
		if($numitems % 2 > 0)
			$first_row += 1;
		$index = 0;
		foreach($this->jobs as $job){
		if($index == 0){
?>
			<ul class="first">
<?php
		}
		else if($index == $first_row){
?>
			</ul>
			<ul class="last">
<?php
		}
		$class = '';
		if($index == ($first_row - 1) || $index == ($numitems -1))
			$class = ' class="last"';
?>
			<li<?php echo $class; ?>>
			<?php if($this->listjobconfig['lj_title']=='1'){ ?>
				<?php $link = 'index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_job&vj=5&oi='.$job->id.'&Itemid='.$this->Itemid; ?>
				<div class="job-tittle"><?php echo $index + 1; ?>. <a href="<?php echo $link?>"><?php echo $job->title; ?></a></div>
			<?php }?>
				<p>
				<?php if($this->listjobconfig['lj_company'] == '1') { ?>
					<span class="company-name">
						<?php $link = 'index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_company&vm=5&md='.$job->companyid.'&jobcat='.$job->jobcategory.'&Itemid='.$this->Itemid; ?>
						<a href="<?php echo $link?>"><?php echo $job->companyname; ?></a>
					</span>
				<?php } ?>
					<span class="post-on">Post on:</span>
					<span class="date"><?php echo date('d F Y',strtotime($job->created)); ?></span>
				</p>
			</li>
<?php
		if($index == $numitems - 1){
?>
			</ul>
<?php
		}
		$index += 1;
	}
}
}else{ // no result found in this category
	echo JText::_('JS_RESULT_NOT_FOUND');
}

} else{ // not allowed job posting
	//Update by Vireak on 09/08/2012
	//Add frame to this warning and some styling
	//---------------------
	echo '<div class="box-list"><div class="head-title"><h2>Oop!</h2></div>';
	echo '<span class="wr_info"><p>'.JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW').'</p>';
	echo '<p>This page is reserved for the authorized job seekers only. </p></span>';
	echo '</div>';
	//---------------------
}
?>
</div>

   


